package com.lancoo.ai.test.base.lib;

import android.os.Handler;
import android.os.Looper;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Global {
    private static final ExecutorService POOL = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
    private final static Handler HANDLER = new Handler(Looper.getMainLooper());

    public static void submit(Runnable command) {
        POOL.submit(command);
    }

    public static void runOnUiThread(Runnable runnable) {
        HANDLER.post(runnable);
    }

    public static void postDelay(Runnable runnable, long delayMillis) {
        HANDLER.postDelayed(runnable, delayMillis);
    }

    public static void removeAllCallback() {
        HANDLER.removeCallbacksAndMessages(null);
    }
}
